home *** CD-ROM | disk | FTP | other *** search
- #define NAME "testNILPack"
- #define REVISION "0"
-
- /* Programmheader
-
- Name: testNILPack
- Author: SDI
- Distribution: PD
- Description: tests Xpk with NIL argument function
- Compileropts: -
- Linkeropts: -l xpkmaster amiga
-
- 1.0 01.04.97 : first version
- */
-
- #include <pragma/dos_lib.h>
- #include <pragma/xpkmaster_lib.h>
- #include <pragma/exec_lib.h>
- #include "SDI_defines.h"
-
- #ifdef __MAXON__
- #define __asm
- #define __saveds
- #endif
-
- struct Library *XpkBase;
-
- LONG __asm __saveds chunkfunc(register __a1 struct XpkProgress *prog)
- {
- switch(prog->xp_Type)
- {
- case XPKPROG_START: PutStr("Start: "); break;
- case XPKPROG_MID: PutStr("\rMid : "); break;
- case XPKPROG_END: PutStr("\rEnd : "); break;
- }
-
- if(prog->xp_Type != XPKPROG_END)
- Printf("%4s: %-8s (%3ld%% done, %2ld%% CF, %6ld cps) %s",
- prog->xp_PackerName, prog->xp_Activity, prog->xp_Done,
- prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
- else
- Printf("%4s: %-8s (%3ldK, %2ld%% CF, %6ld cps) %s\033[K\n",
- prog->xp_PackerName, prog->xp_Activity, prog->xp_ULen >> 10,
- prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
-
- Flush(Output());
- return (LONG) SetSignal(0, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C;
- }
-
- struct Hook chunkhook = { {0}, (ULONG (*)()) chunkfunc};
-
- void main(int argc, char **argv)
- {
- STRPTR obuf = 0;
- ULONG fh, err, obuflen = 0, olen = 0;
-
- if(argc != 2)
- {
- VPrintf("Filename needed\n", 0);
- exit(0);
- }
-
- if(!(XpkBase = OpenLibrary("xpkmaster.library", 4)))
- exit(10);
-
- if(!(fh = Open("NIL:", MODE_NEWFILE)))
- {
- VPrintf("Could not open fh\n", 0);
- CloseLibrary(XpkBase);
- exit(10);
- }
-
- VPrintf("Testing FH Pack access\n", 0);
-
- if((err = XpkPackTags(
- XPK_InName, argv[1],
- XPK_OutFH, fh,
- XPK_ChunkHook, &chunkhook,
- XPK_PackMethod, "NUKE",
- TAG_DONE)))
- XpkPrintFault(err, "FH Pack try");
-
- VPrintf("Testing Name Pack access\n", 0);
-
- if((err = XpkPackTags(
- XPK_InName, argv[1],
- XPK_OutName, "NIL:",
- XPK_ChunkHook, &chunkhook,
- XPK_PackMethod, "NUKE",
- TAG_DONE)))
- XpkPrintFault(err, "Name Pack try");
-
- VPrintf("Producing packed file\n", 0);
-
- if((err = XpkPackTags(
- XPK_InName, argv[1],
- XPK_PackMethod, "NUKE",
- XPK_GetOutBuf, &obuf,
- XPK_GetOutBufLen, &obuflen,
- XPK_GetOutLen, &olen,
- XPK_ChunkHook, &chunkhook,
- TAG_DONE)))
- XpkPrintFault(err, "Normal Pack try");
-
- VPrintf("Testing FH Unpack access\n", 0);
-
- if((err = XpkUnpackTags(
- XPK_InBuf, obuf,
- XPK_InLen, olen,
- XPK_OutFH, fh,
- XPK_ChunkHook, &chunkhook,
- TAG_DONE)))
- XpkPrintFault(err, "FH Unpack try");
-
- VPrintf("Testing direct Unpack access\n", 0);
-
- if((err = XpkUnpackTags(
- XPK_InBuf, obuf,
- XPK_InLen, olen,
- XPK_OutName, "NIL:",
- XPK_ChunkHook, &chunkhook,
- TAG_DONE)))
- XpkPrintFault(err, "Name Unpack try");
-
- if(obuf)
- FreeMem(obuf, obuflen);
-
- if(!Close(fh))
- VPrintf("Could not close fh\n", 0);
- CloseLibrary(XpkBase);
- }
-
-